package com.windy.dao.account;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.windy.dao.BaseDAO;
import com.windy.domain.account.User;
import com.windy.util.TransportObject;

public class UserDAO extends BaseDAO<User> {
  
	@SuppressWarnings("unchecked")
	public User findUserByLoginName(String loginName)
	{
		Criteria criteria = this.getSession().createCriteria(User.class);
		criteria.add(Restrictions.eq("loginName", loginName));
		TransportObject searchResult =  findList(criteria, null, 1, 1);
		if(searchResult.getTotalRecords() >0)
		{
			return (User)((List)searchResult.getResultCollection()).get(0);
		}
		return null;
	}
}
